<?php
/* @var $this GroupsController */
/* @var $model Groups */

$this->breadcrumbs=array(
	'Группы'=>array('admin'),
	'Управления',
);

$this->menu=array(
	array('label'=>'Создать группу', 'url'=>array('create')),
);

?>

<h1>Управление групами</h1>

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'groups-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'afterAjaxUpdate'=>'function(id, data) {$.fn.setPreviewLinksHandler(id, data);}',
	'columns'=>array(
		'name',
		array(
			'name'=>'user_id',
			'value'=>'CSelect::item($data->user_id, "Users","full_name")',
			'filter'=>CSelect::items('Users','full_name'),
		),
		array(
			'name'=>'avatar',
			'filter'=> false,
			'type'=>'raw',
			'value' => function ($data){
				return BaseController::material_image($data->id, $data->avatar, '50','groups/'.$data->id);
			},
		),
		'description',
		'website',
		array(
			'class'=>'CButtonColumn', 
			// 'template'=>'{update}{delete}',
			'template' => '{lock}{unlock}{update}{delete}',
			'buttons'=>array(

				'lock' => array(
					'label'=>'Заблокировать',
					'imageUrl'=>'/images/btn/unlock.png',
					'url'=>'Yii::app()->createUrl("/groups/lock",array("id"=>$data->id))',
					'visible'=>'$data->published==1',
				),

				'unlock' => array(
					'label'=>'Разблокировать',
					'imageUrl'=>'/images/btn/lock.png',
					'url'=>'Yii::app()->createUrl("/groups/unlock",array("id"=>$data->id))',
					'visible'=>'$data->published==0',
				)
			)
		),
	),
)); ?>


